<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录</title>
    <link rel="stylesheet" href="__TEMPLATE__/layui/css/layui.css">
    <style>
        html, body {
            background: #f2f2f2;
        }

        .layadmin-user-login-main {
            width: 375px;
            margin: 0 auto;
            box-sizing: border-box;
        }

        .layadmin-user-login-header {
            text-align: center;
        }

        .layadmin-user-login-box {
            padding: 20px;
        }

        .layadmin-user-login-body .layui-form-item {
            position: relative;
        }

        .layadmin-user-login-icon {
            position: absolute;
            left: 1px;
            top: 1px;
            width: 38px;
            line-height: 36px;
            text-align: center;
            color: #d2d2d2;
        }

        .layadmin-user-login-body .layui-form-item .layui-input {
            padding-left: 38px;
        }
    </style>
</head>
<body>
<div class="layadmin-user-login-main" style="padding-top: 110px;">
    <div class="layadmin-user-login-box layadmin-user-login-header">
        <h2>医院档案管理系统</h2>
    </div>
    <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
        <div class="layui-form-item">
            <label class="layadmin-user-login-icon layui-icon layui-icon-username"></label>
            <input type="text" name="username" placeholder="用户名" class="layui-input"/>
        </div>
        <div class="layui-form-item">
            <label class="layadmin-user-login-icon layui-icon layui-icon-password"></label>
            <input type="password" name="password" placeholder="密码" class="layui-input"/>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="submit">登录</button>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="reg">注册</button>
        </div>
    </div>
</div>
<script src="__TEMPLATE__/layui/jquery-1.7.2.min.js"></script>
<script src="__TEMPLATE__/layui/layui.js"></script>
<script>
    layui.use(['element', 'form'], function () {
        var element = layui.element;
        var form = layui.form;
        form.on('submit(submit)', function (data) {
            var loadIndex = layer.load(1, {
                shade: [0.5, '#000']
            });
            $.ajax({
                url: '?act=checkLogin',
                data: data.field,
                dataType: 'json',
                success: function (res) {
                    layer.close(loadIndex);
                    if (res.code == 0) {
                        window.location.href = 'index.php';
                    } else {
                        layer.msg(res.msg);
                    }
                }
            });
            return false;
        });
        form.on('submit(reg)', function (data) {
            window.location.href = 'reg.php';
            return false;
        });
    });
</script>
</body>
</html>